package com.pllandxzx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pll.pojo.Ruler;
import com.pllandxzx.vo.FeeRuleVo;
import org.apache.ibatis.annotations.*;


@Mapper
public interface FeeRulesMapper extends BaseMapper<Ruler>
{
    //  查询所有收费规则 并分页返回
    @Select("SELECT * FROM ruler ORDER BY ruler_id ASC")
    IPage<Ruler> getAllFeeRules(Page<Ruler> rulerPage);

    //  删除收费规则
    @Delete("DELETE FROM ruler WHERE ruler_id = #{id}")
    int deleteFeeRules(Integer id);

    // 新增收费规则
    @Insert("INSERT INTO ruler (discount, description, type) VALUES " +
            "(#{discount},#{description},#{type})")
    int addFeeRule(FeeRuleVo data);

    //  修改收费规则
    @Update("update ruler set discount=#{data.discount},description=#{data.description},type=#{data.type} WHERE ruler_id = #{id}")
    int updateFeeRule(@Param("id") Integer id,@Param("data") FeeRuleVo data);
}
